<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title></title>
  </head>
  <body>
    <div id="app">
      <div>{{ state }}</div>
      <div>{{ obj }}</div>
      <div>{{ person }}</div>
    </div>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

    <script>
      const { createApp, reactive, nextTick } = Vue;

      const app = createApp({
        setup() {
          // 1. reactive 必须是引用类型，不能是基础类型
          // WRIN  value cannot be made reactive: 1
          const state = reactive(1);

          // 2. 不能替换整个对象
          let obj = reactive({ count: 0 });
          // 上面的 ({ count: 0 }) 引用将不再被追踪(响应性连接已丢失！)
          obj = reactive({ count: 1 });

          // 3. 对解构操作不友好
          const person = reactive({ name: "编程段子" });
          // 当解构时，name 已经与 person.name 断开连接
          let { name } = person;
          // 不会影响 person 代理对象
          name += "哈哈";

          return {
            state,
            obj,
            person,
          };
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
